package com.crx.springbootinit.controller.admin;

import com.crx.springbootinit.annotation.AuthCheck;
import com.crx.springbootinit.annotation.LogApiAnno;
import com.crx.springbootinit.common.BaseResponse;
import com.crx.springbootinit.common.ResultUtils;
import com.crx.springbootinit.model.dto.chat.ChatPageDTO;
import com.crx.springbootinit.model.dto.page.PageVO;
import com.crx.springbootinit.model.vo.chat.ChatVO;
import com.crx.springbootinit.service.IChatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 谢杭延
 * @Date 2024-11-01 12:48
 */
@Api(tags = "后台聊天消息模块接口")
@RestController
@RequestMapping("/admin/chat")
@RequiredArgsConstructor
public class ChatAdminController {

    private final IChatService chatService;

    @ApiOperation("删除聊天记录")
    @DeleteMapping("/delete/{ids}")
    @LogApiAnno(title = "聊天模块", businessType = "DELETE")
    @AuthCheck
    public BaseResponse<Void> delete(@ApiParam("聊天记录id列表") @PathVariable("ids") List<Long> ids){
        chatService.removeByIds(ids);
        return BaseResponse.success();
    }

    @ApiOperation("分页查询聊天记录")
    @GetMapping("/page")
    @LogApiAnno(title = "聊天模块", businessType = "GET")
    @AuthCheck
    public BaseResponse<PageVO<ChatVO>> queryChatPage(ChatPageDTO chatPageDTO){
        PageVO<ChatVO> pageVO = chatService.queryChatPage(chatPageDTO);
        return BaseResponse.success(pageVO);
    }
}
